/*******************************************************************************
 * Copyright (c) 2011 TXT e-solutions SpA
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * This work was performed within the IoT_at_Work Project
 * and partially funded by the European Commission's
 * 7th Framework Programme under the research area ICT-2009.1.3
 * Internet of Things and enterprise environments.
 *
 *
 * Authors:
 *     Cristoforo Seccia (TXT e-solutions SpA)
 *
 * Contributors:
 *      Domenico Rotondi (TXT e-solutions SpA)
 *******************************************************************************/
package it.txt.access.capability.demo.soap.client.view;

import it.txt.access.capability.commons.filter.FilterJKS;
import it.txt.access.capability.commons.filter.FilterXML;
import it.txt.access.capability.demo.soap.client.Resources;
import it.txt.access.capability.demo.soap.client.view.model.ServiceRequestCapabilityModel;
import it.txt.access.capability.demo.soap.client.view.model.ServerResponseInfoModel;
import it.txt.access.capability.demo.soap.client.view.model.UserKeystoreDataModel;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;

/**
 *
 * @author Cristoforo Seccia (TXT e-solutions SpA)
 */
public class ClientGUI extends javax.swing.JFrame {

    protected static final URL APP_LOGO = ClientGUIController.class.getResource(Resources.IMAGES_DIR + "IoT_icon.png");
    protected static final String APP_TITLE = "IoT@Work - Capability Base Authorization Demo Client";
    private static final String OTHER_OPT = "Other...";
    public static final int FINISH_RETURN_CODE = 0;
    public static final int CANCEL_RETURN_CODE = 1;
    public static final int UNDEF_RETURN_CODE = -1;
    public static final int ERROR_RETURN_CODE = 2;
    protected static Icon ICON_SETTINGS;
    protected static Icon ICON_ERROR;
    protected static Icon ICON_OK;
    //The current capability file loaded by the user
    private File currentCapabilityFile = null;
    //The current keystore loaded by the user
    private File currentKeystoreFile = null;
    //The capability file filter
    private FilterXML capabilityXMLFilter;
    //The keystore file filter
    private FilterJKS filterKeystore;
    //The capability file chooser
    private JFileChooser capabilityFileChooser;
    //The keystore file chooser
    private JFileChooser keystoreChooser;
    private ClientGUIController clientGUIController;
    private int returnCode = UNDEF_RETURN_CODE;
    private AboutDialog aboutDialog;

    /** Creates new form ClientGUI */
    protected ClientGUI(ClientGUIController cguic) {
        initComponents();
        setTitle(APP_TITLE);
        clientGUIController = cguic;
        setIconImage(new ImageIcon(APP_LOGO).getImage());
        filterKeystore = new FilterJKS();
        keystoreChooser = new JFileChooser();
        keystoreChooser.setFileFilter(filterKeystore);
        keystoreChooser.setMultiSelectionEnabled(false);
        capabilityXMLFilter = new FilterXML();
        capabilityFileChooser = new JFileChooser();
        capabilityFileChooser.setMultiSelectionEnabled(false);
        capabilityFileChooser.setFileFilter(capabilityXMLFilter);
    }

    //recover the server keystore file
    private void setUserKeystoreFile() {
        if (currentKeystoreFile != null) {
            keystoreChooser.setCurrentDirectory(currentKeystoreFile);
        }
        int returnValue = keystoreChooser.showOpenDialog(this);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            currentKeystoreFile = keystoreChooser.getSelectedFile();
            keystorePathText.setText(currentKeystoreFile.getPath());
            keystorePathText.setCaretPosition(0);
            addUserCertificateDataButton.setEnabled(true);
        }
    }

    private void setUserKeystoreData() {
        UserKeystoreDataModel udsm = new UserKeystoreDataModel();
        udsm.setUserID(userIdentityText.getText());
        udsm.setKeystorePath(currentKeystoreFile.getAbsolutePath());
        udsm.setKeystorePsw(keystorePasswordText.getPassword());
        udsm.setPrivateKeyPsw(privateKeyPasswordText.getPassword());
        clientGUIController.setUserKeystoreData(udsm);
    }

    private void removeUserKeystoreData() {
        currentKeystoreFile = null;
        keystorePathText.setText("");
        userIdentityText.setText("");
        keystorePasswordText.setText("");
        privateKeyPasswordText.setText("");
        addUserCertificateDataButton.setEnabled(false);
    }
    
    private void setUserCapability() {
        if (currentCapabilityFile != null) {
            capabilityFileChooser.setCurrentDirectory(currentCapabilityFile);
        }
        int returnValue = capabilityFileChooser.showOpenDialog(this);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            currentCapabilityFile = capabilityFileChooser.getSelectedFile();
            ServiceRequestCapabilityModel capabilityModel =
                    clientGUIController.setUserCapability(currentCapabilityFile);
            if (capabilityModel != null) {
                capabilityPathText.setText(capabilityModel.getCapabilityPath());
                capabilityPathText.setCaretPosition(0);
                accessRightsCombo.removeAllItems();
                for (String operation : capabilityModel.getOperations()) {
                    accessRightsCombo.addItem(operation);
                }
                accessRightsCombo.addItem(OTHER_OPT);
                resourceIDtext.setText(capabilityModel.getResourceID());
                capabilityIDText.setText(capabilityModel.getCapabilityID());
                sendCapabilityRequestButton.setEnabled(true);
                viewAddedCapabilityButton.setEnabled(true);
            }
        }
    }

    //invalidate the response form
    private void invalidateResponseInformation() {
        responseIDText.setText("");
        responseSignerText.setText("");
        signerKeyIDText.setText("");
        signerKeyIssuerText.setText("");
        serviceResponseStatusArea.setText("");
        serviceResponseStatusArea.validate();
    }

    private void resetUserCapabilityRequest() {
        currentCapabilityFile = null;
        accessRightsCombo.removeAllItems();
        accessRightsCombo.addItem(OTHER_OPT);
        resourceIDtext.setText("");
        capabilityIDText.setText("");
        capabilityPathText.setText("");
        selectedAccessRightText.setText(OTHER_OPT);
        sendCapabilityRequestButton.setEnabled(false);
        viewAddedCapabilityButton.setEnabled(false);        
    }

    private void sendUserCapabilityRequest(){
        String resourceID = resourceIDtext.getText();
        String operation = selectedAccessRightText.getText();
        clientGUIController.sendUserCapabilityRequest(resourceID, operation);
    }


    //Validate the response form
    protected void validateResponseInformation(ServerResponseInfoModel model) {
        responseIDText.setText(model.getResponseID());
        responseSignerText.setText(model.getResponseSigner());
        signerKeyIDText.setText(model.getSignerKeyID());
        signerKeyIssuerText.setText(model.getSignerKeyIssuer());
        serviceResponseStatusArea.setText(model.getServiceResponseStatus());
        serviceResponseStatusArea.setLineWrap(true);
        serviceResponseStatusArea.validate();
    }

    //Append log message to the console
    protected void appendLogMessage(String msg) {
        logTextArea.append(msg);
        logTextArea.setCaretPosition(0);
    }

    //While sending request
    protected void capabilityRequestInProgress(){
        addUserCapabilityButton.setEnabled(false);
        sendCapabilityRequestButton.setEnabled(false);
        resetCapabilityRequestButton.setEnabled(false);
        responseDataFormClearButton.setEnabled(false);
        stopRequestButton.setEnabled(true);
    }

    protected void capabilityRequestFinished(){
        addUserCapabilityButton.setEnabled(true);
        sendCapabilityRequestButton.setEnabled(true);
        resetCapabilityRequestButton.setEnabled(true);
        responseDataFormClearButton.setEnabled(true);
        stopRequestButton.setEnabled(false);
    }

    //Cahnge the status labekl message
    protected void changeStatusLabelText(String value) {
        bottomStatusValueLabel.setText(value);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        requestTabbedPane = new javax.swing.JTabbedPane();
        requestPanel = new javax.swing.JPanel();
        requestResponsePanel = new javax.swing.JPanel();
        responseIDLabel = new javax.swing.JLabel();
        responseSignerLabel = new javax.swing.JLabel();
        signerKeyIDLabel = new javax.swing.JLabel();
        signerKeyIssuerLabel = new javax.swing.JLabel();
        serviceResponseStatusLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        serviceResponseStatusArea = new javax.swing.JTextArea();
        signerKeyIssuerText = new javax.swing.JTextField();
        signerKeyIDText = new javax.swing.JTextField();
        responseSignerText = new javax.swing.JTextField();
        responseIDText = new javax.swing.JTextField();
        requestParametersPanel = new javax.swing.JPanel();
        capabilityPathLabel = new javax.swing.JLabel();
        capabilityPathText = new javax.swing.JTextField();
        addUserCapabilityButton = new javax.swing.JButton();
        resourceIDLabel = new javax.swing.JLabel();
        resourceIDtext = new javax.swing.JTextField();
        capabilityIDLabel = new javax.swing.JLabel();
        capabilityIDText = new javax.swing.JTextField();
        viewAddedCapabilityButton = new javax.swing.JButton();
        resetCapabilityRequestButton = new javax.swing.JButton();
        sendCapabilityRequestButton = new javax.swing.JButton();
        accessRightsCombo = new javax.swing.JComboBox();
        selectedAccessRightlabel = new javax.swing.JLabel();
        selectedAccessRightText = new javax.swing.JTextField();
        accessRightslabel = new javax.swing.JLabel();
        stopRequestButton = new javax.swing.JButton();
        requestResponseButtonsPanel = new javax.swing.JPanel();
        responseDataFormClearButton = new javax.swing.JButton();
        parametersPanel = new javax.swing.JPanel();
        paremetersUserDataPanel = new javax.swing.JPanel();
        userIdentityLabel = new javax.swing.JLabel();
        keystorePathLabel = new javax.swing.JLabel();
        keystorePasswordLabel = new javax.swing.JLabel();
        privateKeyPasswordLabel = new javax.swing.JLabel();
        userIdentityText = new javax.swing.JTextField();
        keystorePathText = new javax.swing.JTextField();
        privateKeyPasswordText = new javax.swing.JPasswordField();
        keystorePasswordText = new javax.swing.JPasswordField();
        setUserKeystoreFileButton = new javax.swing.JButton();
        removeUserCertificateDataButton = new javax.swing.JButton();
        addUserCertificateDataButton = new javax.swing.JButton();
        logPanel = new javax.swing.JPanel();
        logTextAreaPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        logTextArea = new javax.swing.JTextArea();
        logClearButtonPanel = new javax.swing.JPanel();
        clerLogButton = new javax.swing.JButton();
        battomStatusPanel = new javax.swing.JPanel();
        bottomStatusLabel = new javax.swing.JLabel();
        bottomStatusValueLabel = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        requestResponsePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Response Information"));

        responseIDLabel.setText("Response ID");

        responseSignerLabel.setText("Response Signer");

        signerKeyIDLabel.setText("Signer Key ID");

        signerKeyIssuerLabel.setText("Signer Key Issuer");

        serviceResponseStatusLabel.setText("Service Response Status");

        serviceResponseStatusArea.setColumns(20);
        serviceResponseStatusArea.setEditable(false);
        serviceResponseStatusArea.setRows(5);
        jScrollPane2.setViewportView(serviceResponseStatusArea);

        signerKeyIssuerText.setEditable(false);

        signerKeyIDText.setEditable(false);

        responseSignerText.setEditable(false);

        responseIDText.setEditable(false);

        javax.swing.GroupLayout requestResponsePanelLayout = new javax.swing.GroupLayout(requestResponsePanel);
        requestResponsePanel.setLayout(requestResponsePanelLayout);
        requestResponsePanelLayout.setHorizontalGroup(
            requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(requestResponsePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(serviceResponseStatusLabel)
                    .addComponent(signerKeyIssuerLabel)
                    .addComponent(signerKeyIDLabel)
                    .addComponent(responseSignerLabel)
                    .addComponent(responseIDLabel))
                .addGap(18, 18, 18)
                .addGroup(requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
                    .addComponent(responseIDText, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
                    .addComponent(responseSignerText, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
                    .addComponent(signerKeyIDText, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
                    .addComponent(signerKeyIssuerText, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE))
                .addContainerGap())
        );
        requestResponsePanelLayout.setVerticalGroup(
            requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(requestResponsePanelLayout.createSequentialGroup()
                .addGroup(requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(responseIDLabel)
                    .addComponent(responseIDText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(responseSignerLabel)
                    .addComponent(responseSignerText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(signerKeyIDLabel)
                    .addComponent(signerKeyIDText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(signerKeyIssuerLabel)
                    .addComponent(signerKeyIssuerText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestResponsePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(serviceResponseStatusLabel)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE))
                .addContainerGap())
        );

        requestParametersPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Request Parameters"));

        capabilityPathLabel.setText("Capability");

        addUserCapabilityButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Open_16x16.png"))); // NOI18N
        addUserCapabilityButton.setText("Open");
        addUserCapabilityButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addUserCapabilityButtonActionPerformed(evt);
            }
        });

        resourceIDLabel.setText("Resource ID");

        capabilityIDLabel.setText("Capability ID");

        capabilityIDText.setEditable(false);

        viewAddedCapabilityButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Preview_16x16.png"))); // NOI18N
        viewAddedCapabilityButton.setText("View");
        viewAddedCapabilityButton.setEnabled(false);
        viewAddedCapabilityButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewAddedCapabilityButtonActionPerformed(evt);
            }
        });

        resetCapabilityRequestButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Redo_16x16.png"))); // NOI18N
        resetCapabilityRequestButton.setText("Reset");
        resetCapabilityRequestButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetCapabilityRequestButtonActionPerformed(evt);
            }
        });

        sendCapabilityRequestButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Send_16x16.png"))); // NOI18N
        sendCapabilityRequestButton.setText("Send Request");
        sendCapabilityRequestButton.setEnabled(false);
        sendCapabilityRequestButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendCapabilityRequestButtonActionPerformed(evt);
            }
        });

        accessRightsCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Other..." }));
        accessRightsCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                accessRightsComboActionPerformed(evt);
            }
        });

        selectedAccessRightlabel.setText("Operation Name");

        selectedAccessRightText.setText("Other...");

        accessRightslabel.setText("Select the operation");

        stopRequestButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Stop_16x16.png"))); // NOI18N
        stopRequestButton.setText("Stop Request");
        stopRequestButton.setEnabled(false);
        stopRequestButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopRequestButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout requestParametersPanelLayout = new javax.swing.GroupLayout(requestParametersPanel);
        requestParametersPanel.setLayout(requestParametersPanelLayout);
        requestParametersPanelLayout.setHorizontalGroup(
            requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(requestParametersPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(requestParametersPanelLayout.createSequentialGroup()
                        .addComponent(capabilityPathLabel)
                        .addGap(68, 68, 68)
                        .addComponent(capabilityPathText, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(addUserCapabilityButton)
                        .addGap(18, 18, 18)
                        .addComponent(viewAddedCapabilityButton))
                    .addGroup(requestParametersPanelLayout.createSequentialGroup()
                        .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(resourceIDLabel)
                            .addComponent(capabilityIDLabel))
                        .addGap(54, 54, 54)
                        .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(capabilityIDText, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
                            .addComponent(resourceIDtext, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)))
                    .addGroup(requestParametersPanelLayout.createSequentialGroup()
                        .addComponent(accessRightslabel)
                        .addGap(18, 18, 18)
                        .addComponent(accessRightsCombo, 0, 409, Short.MAX_VALUE))
                    .addGroup(requestParametersPanelLayout.createSequentialGroup()
                        .addComponent(selectedAccessRightlabel)
                        .addGap(37, 37, 37)
                        .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, requestParametersPanelLayout.createSequentialGroup()
                                .addComponent(sendCapabilityRequestButton)
                                .addGap(18, 18, 18)
                                .addComponent(stopRequestButton)
                                .addGap(18, 18, 18)
                                .addComponent(resetCapabilityRequestButton))
                            .addComponent(selectedAccessRightText, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE))))
                .addContainerGap())
        );
        requestParametersPanelLayout.setVerticalGroup(
            requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(requestParametersPanelLayout.createSequentialGroup()
                .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(capabilityPathLabel)
                    .addComponent(capabilityPathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(viewAddedCapabilityButton)
                    .addComponent(addUserCapabilityButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(resourceIDLabel)
                    .addComponent(resourceIDtext, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(capabilityIDLabel)
                    .addComponent(capabilityIDText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(accessRightsCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(accessRightslabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(selectedAccessRightlabel)
                    .addComponent(selectedAccessRightText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(requestParametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(resetCapabilityRequestButton)
                    .addComponent(stopRequestButton)
                    .addComponent(sendCapabilityRequestButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        requestResponseButtonsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        responseDataFormClearButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Remove_16x16.png"))); // NOI18N
        responseDataFormClearButton.setText("Clear");
        responseDataFormClearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                responseDataFormClearButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout requestResponseButtonsPanelLayout = new javax.swing.GroupLayout(requestResponseButtonsPanel);
        requestResponseButtonsPanel.setLayout(requestResponseButtonsPanelLayout);
        requestResponseButtonsPanelLayout.setHorizontalGroup(
            requestResponseButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, requestResponseButtonsPanelLayout.createSequentialGroup()
                .addContainerGap(457, Short.MAX_VALUE)
                .addComponent(responseDataFormClearButton)
                .addContainerGap())
        );
        requestResponseButtonsPanelLayout.setVerticalGroup(
            requestResponseButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, requestResponseButtonsPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(responseDataFormClearButton)
                .addContainerGap())
        );

        javax.swing.GroupLayout requestPanelLayout = new javax.swing.GroupLayout(requestPanel);
        requestPanel.setLayout(requestPanelLayout);
        requestPanelLayout.setHorizontalGroup(
            requestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, requestPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(requestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(requestResponsePanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(requestParametersPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(requestResponseButtonsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        requestPanelLayout.setVerticalGroup(
            requestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(requestPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(requestParametersPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(requestResponsePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(requestResponseButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        requestTabbedPane.addTab("Manage Service Request", new javax.swing.ImageIcon(getClass().getResource("/images/icons_24x24/Globe_24x24.png")), requestPanel); // NOI18N

        paremetersUserDataPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("User Data Section"));

        userIdentityLabel.setText("User Identity");

        keystorePathLabel.setText("Keystore");

        keystorePasswordLabel.setText("Keystore Password");

        privateKeyPasswordLabel.setText("Private Key Password");

        setUserKeystoreFileButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Open_16x16.png"))); // NOI18N
        setUserKeystoreFileButton.setText("Open");
        setUserKeystoreFileButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                setUserKeystoreFileButtonActionPerformed(evt);
            }
        });

        removeUserCertificateDataButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Remove_16x16.png"))); // NOI18N
        removeUserCertificateDataButton.setText("Clear");
        removeUserCertificateDataButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeUserCertificateDataButtonActionPerformed(evt);
            }
        });

        addUserCertificateDataButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Check_16x16.png"))); // NOI18N
        addUserCertificateDataButton.setText("Set");
        addUserCertificateDataButton.setEnabled(false);
        addUserCertificateDataButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addUserCertificateDataButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout paremetersUserDataPanelLayout = new javax.swing.GroupLayout(paremetersUserDataPanel);
        paremetersUserDataPanel.setLayout(paremetersUserDataPanelLayout);
        paremetersUserDataPanelLayout.setHorizontalGroup(
            paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paremetersUserDataPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(paremetersUserDataPanelLayout.createSequentialGroup()
                        .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(privateKeyPasswordLabel)
                            .addComponent(keystorePasswordLabel)
                            .addComponent(userIdentityLabel)
                            .addComponent(keystorePathLabel))
                        .addGap(18, 18, 18)
                        .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, paremetersUserDataPanelLayout.createSequentialGroup()
                                .addComponent(keystorePathText, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(setUserKeystoreFileButton))
                            .addComponent(userIdentityText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
                            .addComponent(privateKeyPasswordText, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
                            .addComponent(keystorePasswordText, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, paremetersUserDataPanelLayout.createSequentialGroup()
                        .addComponent(addUserCertificateDataButton)
                        .addGap(18, 18, 18)
                        .addComponent(removeUserCertificateDataButton)))
                .addContainerGap())
        );
        paremetersUserDataPanelLayout.setVerticalGroup(
            paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paremetersUserDataPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(keystorePathLabel)
                    .addComponent(keystorePathText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(setUserKeystoreFileButton))
                .addGap(18, 18, 18)
                .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(userIdentityLabel)
                    .addComponent(userIdentityText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(keystorePasswordLabel)
                    .addComponent(keystorePasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(privateKeyPasswordLabel)
                    .addComponent(privateKeyPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 385, Short.MAX_VALUE)
                .addGroup(paremetersUserDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(removeUserCertificateDataButton)
                    .addComponent(addUserCertificateDataButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout parametersPanelLayout = new javax.swing.GroupLayout(parametersPanel);
        parametersPanel.setLayout(parametersPanelLayout);
        parametersPanelLayout.setHorizontalGroup(
            parametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(parametersPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(paremetersUserDataPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        parametersPanelLayout.setVerticalGroup(
            parametersPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(parametersPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(paremetersUserDataPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        requestTabbedPane.addTab("Configuration Parameters", new javax.swing.ImageIcon(getClass().getResource("/images/icons_24x24/Properties_24x24.png")), parametersPanel); // NOI18N

        logTextAreaPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Capability Based Authorization - Events Log"));

        logTextArea.setColumns(20);
        logTextArea.setEditable(false);
        logTextArea.setRows(5);
        jScrollPane1.setViewportView(logTextArea);

        logClearButtonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        clerLogButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Remove_16x16.png"))); // NOI18N
        clerLogButton.setText("Clear");
        clerLogButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clerLogButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout logClearButtonPanelLayout = new javax.swing.GroupLayout(logClearButtonPanel);
        logClearButtonPanel.setLayout(logClearButtonPanelLayout);
        logClearButtonPanelLayout.setHorizontalGroup(
            logClearButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logClearButtonPanelLayout.createSequentialGroup()
                .addContainerGap(433, Short.MAX_VALUE)
                .addComponent(clerLogButton)
                .addContainerGap())
        );
        logClearButtonPanelLayout.setVerticalGroup(
            logClearButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logClearButtonPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(clerLogButton)
                .addContainerGap())
        );

        javax.swing.GroupLayout logTextAreaPanelLayout = new javax.swing.GroupLayout(logTextAreaPanel);
        logTextAreaPanel.setLayout(logTextAreaPanelLayout);
        logTextAreaPanelLayout.setHorizontalGroup(
            logTextAreaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logTextAreaPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(logTextAreaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 524, Short.MAX_VALUE)
                    .addComponent(logClearButtonPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        logTextAreaPanelLayout.setVerticalGroup(
            logTextAreaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logTextAreaPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(logClearButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout logPanelLayout = new javax.swing.GroupLayout(logPanel);
        logPanel.setLayout(logPanelLayout);
        logPanelLayout.setHorizontalGroup(
            logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(logPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logTextAreaPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        logPanelLayout.setVerticalGroup(
            logPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(logPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logTextAreaPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        requestTabbedPane.addTab("View Log", new javax.swing.ImageIcon(getClass().getResource("/images/icons_24x24/Text Document_24x24.png")), logPanel); // NOI18N

        battomStatusPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        bottomStatusLabel.setText("Status: ");

        javax.swing.GroupLayout battomStatusPanelLayout = new javax.swing.GroupLayout(battomStatusPanel);
        battomStatusPanel.setLayout(battomStatusPanelLayout);
        battomStatusPanelLayout.setHorizontalGroup(
            battomStatusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, battomStatusPanelLayout.createSequentialGroup()
                .addContainerGap(525, Short.MAX_VALUE)
                .addComponent(bottomStatusLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bottomStatusValueLabel)
                .addContainerGap())
        );
        battomStatusPanelLayout.setVerticalGroup(
            battomStatusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, battomStatusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(bottomStatusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                .addComponent(bottomStatusValueLabel))
        );

        fileMenu.setText("File");

        exitMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Log Out_16x16.png"))); // NOI18N
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText("Help");

        aboutMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Information_16x16.png"))); // NOI18N
        aboutMenuItem.setText("About");
        aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(requestTabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)
                    .addComponent(battomStatusPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(requestTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 661, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(battomStatusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void clerLogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clerLogButtonActionPerformed
        logTextArea.setText("");
    }//GEN-LAST:event_clerLogButtonActionPerformed

    private void accessRightsComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accessRightsComboActionPerformed
        if (accessRightsCombo.getSelectedItem() != null) {
            String selectedOpt = (String) accessRightsCombo.getSelectedItem();
            selectedAccessRightText.setEditable(selectedOpt.equals(OTHER_OPT));
            selectedAccessRightText.setText(selectedOpt);
        }
    }//GEN-LAST:event_accessRightsComboActionPerformed

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        close(FINISH_RETURN_CODE);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void setUserKeystoreFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setUserKeystoreFileButtonActionPerformed
        setUserKeystoreFile();
    }//GEN-LAST:event_setUserKeystoreFileButtonActionPerformed

    private void addUserCertificateDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addUserCertificateDataButtonActionPerformed
        setUserKeystoreData();
    }//GEN-LAST:event_addUserCertificateDataButtonActionPerformed

    private void removeUserCertificateDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeUserCertificateDataButtonActionPerformed
        removeUserKeystoreData();
    }//GEN-LAST:event_removeUserCertificateDataButtonActionPerformed

    private void addUserCapabilityButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addUserCapabilityButtonActionPerformed
        setUserCapability();
    }//GEN-LAST:event_addUserCapabilityButtonActionPerformed

    private void viewAddedCapabilityButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAddedCapabilityButtonActionPerformed
        clientGUIController.viewUserCapability();
    }//GEN-LAST:event_viewAddedCapabilityButtonActionPerformed

    private void sendCapabilityRequestButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendCapabilityRequestButtonActionPerformed
        sendUserCapabilityRequest();
    }//GEN-LAST:event_sendCapabilityRequestButtonActionPerformed

    private void resetCapabilityRequestButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetCapabilityRequestButtonActionPerformed
        resetUserCapabilityRequest();
    }//GEN-LAST:event_resetCapabilityRequestButtonActionPerformed

    private void responseDataFormClearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_responseDataFormClearButtonActionPerformed
        invalidateResponseInformation();
    }//GEN-LAST:event_responseDataFormClearButtonActionPerformed

    private void stopRequestButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopRequestButtonActionPerformed
        clientGUIController.stopCapabilityRequest();
    }//GEN-LAST:event_stopRequestButtonActionPerformed

    private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
        if(aboutDialog == null){
            aboutDialog = new AboutDialog(this,false);
        }
        aboutDialog.setVisible(true);
    }//GEN-LAST:event_aboutMenuItemActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JComboBox accessRightsCombo;
    private javax.swing.JLabel accessRightslabel;
    private javax.swing.JButton addUserCapabilityButton;
    private javax.swing.JButton addUserCertificateDataButton;
    private javax.swing.JPanel battomStatusPanel;
    private javax.swing.JLabel bottomStatusLabel;
    private javax.swing.JLabel bottomStatusValueLabel;
    private javax.swing.JLabel capabilityIDLabel;
    private javax.swing.JTextField capabilityIDText;
    private javax.swing.JLabel capabilityPathLabel;
    private javax.swing.JTextField capabilityPathText;
    private javax.swing.JButton clerLogButton;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel keystorePasswordLabel;
    private javax.swing.JPasswordField keystorePasswordText;
    private javax.swing.JLabel keystorePathLabel;
    private javax.swing.JTextField keystorePathText;
    private javax.swing.JPanel logClearButtonPanel;
    private javax.swing.JPanel logPanel;
    private javax.swing.JTextArea logTextArea;
    private javax.swing.JPanel logTextAreaPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JPanel parametersPanel;
    private javax.swing.JPanel paremetersUserDataPanel;
    private javax.swing.JLabel privateKeyPasswordLabel;
    private javax.swing.JPasswordField privateKeyPasswordText;
    private javax.swing.JButton removeUserCertificateDataButton;
    private javax.swing.JPanel requestPanel;
    private javax.swing.JPanel requestParametersPanel;
    private javax.swing.JPanel requestResponseButtonsPanel;
    private javax.swing.JPanel requestResponsePanel;
    private javax.swing.JTabbedPane requestTabbedPane;
    private javax.swing.JButton resetCapabilityRequestButton;
    private javax.swing.JLabel resourceIDLabel;
    private javax.swing.JTextField resourceIDtext;
    private javax.swing.JButton responseDataFormClearButton;
    private javax.swing.JLabel responseIDLabel;
    private javax.swing.JTextField responseIDText;
    private javax.swing.JLabel responseSignerLabel;
    private javax.swing.JTextField responseSignerText;
    private javax.swing.JTextField selectedAccessRightText;
    private javax.swing.JLabel selectedAccessRightlabel;
    private javax.swing.JButton sendCapabilityRequestButton;
    private javax.swing.JTextArea serviceResponseStatusArea;
    private javax.swing.JLabel serviceResponseStatusLabel;
    private javax.swing.JButton setUserKeystoreFileButton;
    private javax.swing.JLabel signerKeyIDLabel;
    private javax.swing.JTextField signerKeyIDText;
    private javax.swing.JLabel signerKeyIssuerLabel;
    private javax.swing.JTextField signerKeyIssuerText;
    private javax.swing.JButton stopRequestButton;
    private javax.swing.JLabel userIdentityLabel;
    private javax.swing.JTextField userIdentityText;
    private javax.swing.JButton viewAddedCapabilityButton;
    // End of variables declaration//GEN-END:variables

    //The client return code
    protected int getReturnCode() {
        return returnCode;
    }
    
    //Alert all the lister that the client form is closing
    private void close(int code) {
        returnCode = code;
        dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }

    static {
        ICON_SETTINGS =
                new javax.swing.ImageIcon(ClientGUI.class.getResource("/images/icons_16x16/Settings_16x16.png"));
        ICON_OK =
                new javax.swing.ImageIcon(ClientGUI.class.getResource("/images/icons_16x16/Check_16x16.png"));
        ICON_ERROR =
                new javax.swing.ImageIcon(ClientGUI.class.getResource("/images/icons_16x16/Cancel_16x16.png"));
    }
}
